package com.itrip.controller;

import com.itrip.dto.ResponseDTO;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 全局异常处理
 */
@ControllerAdvice
@ResponseBody
public class ExceptionController {

    /**
     * 捕获所有异常
     * @param e 捕获到的异常
     * @return 响应的数据
     */
    @ExceptionHandler(value = {Exception.class})
    public ResponseDTO handleException(Exception e){

        e.printStackTrace();
        return new ResponseDTO(103,"请求异常："+e,null);
    }
}
